package model

import (
	"manuscript-service/servicerpc/servicerpc"

	"gorm.io/gorm"
)

type User struct {
	gorm.Model
	Title  string `json:"Title"`
	Num    int    `json:"Num"`
	Image  string `json:"Image"`
	GoodId int    `json:"GoodId"`
}

func (u *User) UserAdd(db *gorm.DB) error {

	return db.Debug().Create(u).Error

}

func (u *User) UsersCfAdd(db *gorm.DB, title string) error {

	return db.Debug().Where("title=?", title).First(u).Error

}

func (u *User) UserCjAdd(db *gorm.DB, title string) error {

	return db.Debug().Where("title=?", title).First(u).Error

}

func (u *User) UserList(db *gorm.DB, user []*servicerpc.UserList) error {

	return db.Debug().Where("user=?", user).Find(u).Error

}

type Good struct {
	gorm.Model
	GoodName string `json:"GoodName"`
}

func (g *Good) GoodsAdd(db *gorm.DB) error {

	return db.Debug().Create(g).Error

}
